package com.ruibang.glass.quality.constant;


import java.util.Arrays;

/**
 * @author 宋锦康
 */
public class XbarAbnormalJudgeEnums {

    public enum type {
        ONE(1, "一个点，距离中心线大于K个标准差", 3),
        TWO(2, "连续K个点在中心线同一侧", 9),
        THREE(3, "连续K个点， 全部递增或全部递减", 6),
        FOUR(4, "连续K个点，上下交错", 14),
        FIVE(5, "K+1个点中有K个点，距离中心线（同侧）大于2个标准差", 2),
        SIX(6, "K+1个点中有K个点，距离中心线（同侧）大于1个标准差", 4),
        SEVEN(7, "连续K个点，距离中心线（任一侧）1个标准差以内", 15),
        EIGHT(8, "连续K个点，距离中心线（任一侧）大于1个标准差", 8),
        ;

        private final Integer code;
        private final String desc;
        private final Integer defaultKValue;

        type(Integer code, String desc, Integer defaultKValue) {
            this.code = code;
            this.desc = desc;
            this.defaultKValue = defaultKValue;
        }

        public Integer getCode() {
            return code;
        }

        public String getDesc() {
            return desc;
        }

        public Integer getDefaultKValue() {
            return defaultKValue;
        }

        public static type getByCode(Integer code) {
            if (code == null) {
                return null;
            }
            return Arrays.stream(type.values()).filter(o -> code.equals(o.getCode())).findFirst().get();
        }
    }

    /**
     * 是否选中
     */
    public enum selectFlag {
        YES(1, "是"),
        NO(2, "否");

        private final Integer code;
        private final String desc;

        selectFlag(Integer code, String desc) {
            this.code = code;
            this.desc = desc;
        }

        public Integer getCode() {
            return code;
        }

        public String getDesc() {
            return desc;
        }

    }


}
